# 在文件开头添加缺失的导入
import os
import sys
from datetime import datetime

# 修改项目路径配置
sys.path.insert(0, os.path.abspath('../../seatools'))  # 根据实际层级调整
sys.path.insert(0, os.path.abspath('../../cookiecutter-seatools'))

# 确保语言设置为中文
language = 'zh_CN'
html_search_language = 'zh'  # 使用中文搜索

# 主题配置
html_theme = 'sphinx_rtd_theme'
html_theme_options = {
    'logo_only': False,
    # 'display_version': True,  # 注释掉不支持的选项
    'prev_next_buttons_location': 'both',
    'style_external_links': True,
    'style_nav_header_background': '#2980B9',
    'collapse_navigation': False,
    'sticky_navigation': True,
    'navigation_depth': 4,
    'includehidden': True,
    'titles_only': False
}

# 添加项目信息
project = 'Seatools'
copyright = '2024, Seatools Team'
author = 'Seatools Team'
version = '1.0.0'
release = '1.0.0'

# 添加扩展
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.intersphinx',
    'sphinx.ext.viewcode',
    'sphinx.ext.napoleon',
    'sphinx.ext.todo',
    'sphinx_rtd_theme'
]

# 多项目配置
intersphinx_mapping = {
    # 暂时禁用交叉引用
    # 'seatools': ('https://seatools-py.github.io/seatools', None),
    # 'cookiecutter': ('https://seatools-py.github.io/cookiecutter-seatools', None)
}

# 在文件末尾添加
suppress_warnings = [
    'autosectionlabel.*',  # 屏蔽自动标签警告
    'toc.duplicate_entry'  # 屏蔽重复条目警告
]

html_context = {
    'display_github': True,
    'github_user': 'seatools-py',
    'github_repo': 'seatools',
    'github_version': 'main',
    'conf_py_path': '/docs/source/',
    'versions': {
        'Latest (1.0.0)': '#',
        '0.9.0': 'https://seatools-py.github.io/seatools/v0.9.0'
    }
}

# 注释掉有问题的搜索配置
# html_search_options = {
#     'dict': 'path/to/jieba/dict.txt',
#     'lang': 'zh_CN'
# }

def setup(app):
    app.add_config_value('build_time', datetime.now().strftime('%Y-%m-%d %H:%M'), 'html') 